<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Creates a new binary data object</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="class.mongobindata.html">« MongoBinData</a></li>
      <li style="float: right;"><a href="mongobindata.tostring.html">MongoBinData::__toString »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.mongobindata.html">MongoBinData</a></li>
    <li>Creates a new binary data object</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="mongobindata.construct" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">MongoBinData::__construct</h1>
  <p class="verinfo">(PECL mongo &gt;= 0.8.1)</p><p class="refpurpose"><span class="refname">MongoBinData::__construct</span> &mdash; <span class="dc-title">Creates a new binary data object</span></p>

 </div>

 <div id="mongobindata.construct-soft-deprecation-notice" class="soft-deprecation-notice">
  <blockquote class="sidebar">
   <p class="para">This extension that defines this method
is deprecated. Instead, the <a href="" class="link">MongoDB</a> extension should be used.
Alternatives to this method include:</p>
   <ul class="simplelist">
    <li class="member"><span class="methodname"><strong>MongoDB\BSON\Binary::__construct()</strong></span></li>
   </ul>
  </blockquote>
 </div>

 <div class="refsect1 description" id="refsect1-mongobindata.construct-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>MongoBinData::__construct</strong></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$data</code></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter">$type</code><span class="initializer"> = 0</span></span>)</div>

  <p class="para rdfs-comment">
   Creates a new binary data object.
  </p>
  <p class="para">
   There are seven types of binary data currently recognized by the BSON spec,
   which are defined as
   <a href="class.mongobindata.html#mongobindata.constants.types" class="link">class constants</a>. For
   backwards compatibility, the PHP driver uses
   <strong><code>MongoBinData::BYTE_ARRAY</code></strong> as the default; however, this
   may change to <strong><code>MongoBinData::GENERIC</code></strong> in the future.
   Users are encouraged to specify a type instead of relying on the default.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-mongobindata.construct-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>

    
     <dt>

      <code class="parameter">data</code>
     </dt>

     <dd>

      <p class="para">
       Binary data.
      </p>
     </dd>

         
    
     <dt>

      <code class="parameter">type</code>
     </dt>

     <dd>

      <p class="para">
       Data type.
      </p>
     </dd>

         
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-mongobindata.construct-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns a new binary data object.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-mongobindata.construct-changelog">
  <h3 class="title">Changelog</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Version</th>
       <th>Description</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>PECL mongo 1.5.0</td>
       <td>
        The default changed from <code class="literal">2</code>
        (<strong><code>MongoBinData::BYTE_ARRAY</code></strong>) to
        <code class="literal">0</code> (<strong><code>MongoBinData::GENERIC</code></strong>).
       </td>
      </tr>

      <tr>
       <td>PECL mongo 1.2.11</td>
       <td>
        Emits <strong><code>E_DEPRECATED</code></strong> when the second argument is not
        used. The default value for <code class="parameter">type</code> may change in
        the near future.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


</div></div></div></body></html>